<?php
/**
* Creater : phuongtt
* Date: 5/1/2011
* Idea: Lay danh sach quyen thuoc nhom
*/

class listxml_modPermission extends Efy_DB_Connection {
	/**
	 * Creater : HUNGVM
	 * Date : 18/09/2009
	 *
	 * @param $scode : Ma nhom quyen
	 * @param $sTagName : Ten then luu nhom quyen
	 * @return Mang luu thong tin nhom quyen
	 */
	public function PermissionGroupGetAll($scode, $sTagName){		
		$sql = "EfyLib_PermissionGroupGetAll";
		$sql = $sql . "'" . $scode . "'";
		$sql = $sql . ",'" . $sTagName . "'";		
		//echo $sql; 
		try{
			$arrResult = $this->adodbQueryDataInNameMode($sql);
		}catch (Exception $e){
			echo $e->getMessage();
		}
		return $arrResult;
	}

		/**
	 * Creater : HUNGVM
	 * Date : 21/09/2009
	 *
	 * @param $sStaffIdList : Danh sach NSD
	 * @return Mang luu thong tin quyen cua $sStaffIdList
	 */
	public function StaffPermissionGetAll($sStaffIdList, $sDelimitor = "!~~!"){		
		$sql = "EfyLib_StaffPermissionGetAll ";
		$sql = $sql . "'" . $sStaffIdList . "'";				
		$sql = $sql . ",'" . $sDelimitor . "'";				
		//echo $sql; 
		try{
			$arrResult = $this->adodbQueryDataInNameMode($sql);
		}catch (Exception $e){
			echo $e->getMessage();
		}
		return $arrResult;
	}
	
	/**
	 * Creater : HUNGVM
	 * Date : 21/09/2009
	 * Idea : Tao phuong thuc update quyen cho NSD
	 *
	 * @param $arrParameter : Mang luu thong tin cac tham so can update
	 * @return RET_ERROR : <>'' Neu loi xay ra; = '' Not Error
	 */
	public function StaffPermissionUpdate($arrParameter){
		$psSql = "Exec EfyLib_StaffPermissionUpdate ";	
		$psSql .= "'" . $arrParameter['FK_STAFF_ID_LIST'] . "'";
		$psSql .= ",'" . $arrParameter['GROUP'] . "'";	
		//Thuc thi lenh SQL		
		//echo htmlspecialchars($psSql); exit;
		try {
			$arrTempResult = $this->adodbExecSqlString($psSql) ; 
			$Result = $arrTempResult['RET_ERROR'];
		}catch (Exception $e){
			echo $e->getMessage();
		};
		//Return result
		return $Result;		
	}
	public function USERStaffGetAll ($sStatus,$sPkUnitId,$sFullTextSearch,$sOwnerCode){
		$dblinkUser = Efy_Init_Config::_setDbLinkUser();
		$psSql = "Exec $dblinkUser .dbo.USER_StaffGetAll ";
		$psSql .= "'"  . $sStatus . "'";
		$psSql .= ",'"  . $sPkUnitId . "'";
		$psSql .= ",'"  . $sFullTextSearch . "'";
		$psSql .= ",'"  . $sOwnerCode . "'";
		//echo  "<br>". $psSql . "<br>"; 
		//exit;
		try{
			$arrResult = $this->adodbQueryDataInNameMode($psSql);//Thuc thi chuoi sql va tra ra mang da chieu
		}catch (Exception $e){
			echo $e->getMessage();
		};
		return $arrResult;
	}
	public function OwnerCodeFromUserGetAll ($sOwnerCode, $sCode){
		$dblinkUser = Efy_Init_Config::_setDbLinkUser(); 
		$sql = "Exec $dblinkUser .dbo.EfyLib_ListGetAllbyListtypeCode ";
		$sql = $sql . " '" . $sOwnerCode . "'";
		$sql = $sql . " ,'" . $sCode . "'";
		echo $sql . '<br>';//exit;
		try {
			$arrObject = $this->adodbQueryDataInNameMode($sql,$optCache);
		}catch (Exception $e){
			echo $e->getMessage();
		}
		return $arrObject;
	}
	public function USERUnitGetAll($sStatus,$sFullTextSearch,$sOwnercode){
		$dblinkUser = Efy_Init_Config::_setDbLinkUser();
		$psSql = "Exec $dblinkUser .dbo.USER_UnitGetAll ";
		$psSql .= "'"  . $sStatus . "'";
		$psSql .= ",'"  . $sFullTextSearch . "'";
		$psSql .= ",'"  . $sOwnercode . "'";
		//echo  "<br>". $psSql . "<br>"; 
		//exit;
		try {			
			$arrResult = $this->adodbQueryDataInNameMode($psSql);
		}catch (Exception $e){
			echo $e->getMessage();
		};				
		return $arrResult;
	}
	public function USERStaffGetAllBySearch ($sFullTextSearch){
		$psSql = "Exec USER_StaffGetAllBySearch ";
		$psSql .= "'"  . $sFullTextSearch . "'";
		//echo  "<br>". $psSql . "<br>"; 
		//exit;
		try{
			$arrResult = $this->adodbQueryDataInNameMode($psSql);//Thuc thi chuoi sql va tra ra mang da chieu
		}catch (Exception $e){
			echo $e->getMessage();
		};
		return $arrResult;
	}
	public function StaffPermissionDelete ($iStaffIdList){
		$psSql = "Exec USER_StaffPermissionDelete ";
		$psSql .= "'"  . $iStaffIdList . "'";
		//echo  "<br>". $psSql . "<br>"; 
		//exit;
		try{
			$arrResult = $this->adodbExecSqlString($psSql);//Thuc thi chuoi sql va tra ra mang da chieu
		}catch (Exception $e){
			echo $e->getMessage();
		};
		return $arrResult;
	}	
}
?>